const URL_PREFIX = "http://www.pudge.wang:4000";

const http = {
    get(url, params) {
        if (params) {
            console.log(params);
        }
        return new Promise((resolve) => {
            fetch(URL_PREFIX + url)
                .then((response) => response.json())
                .then(async(res) => {
                    resolve(res);
                });
        });
    },
    post(url, data) {
        return new Promise((resolve) => {
            fetch(URL_PREFIX + url, {
                    body: JSON.stringify(data),
                    headers: { "content-type": "application/json" },
                    method: "POST",
                })
                .then((response) => response.json())
                .then((res) => {
                    resolve(res);
                });
        });
    },

};
export default http;